import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import Login from '../views/Login.vue'
import Welcome from "../components/Welcome"
import Users from "../components/user/Users"
import Category from "../components/item/Category"
import Specification from "../components/item/specification/Specification"
import Goods from "../components/item/goods/Goods"
import Brands from "../components/item/Brands"
import Orders from "../components/order/Orders"
import IndexRec from "../components/recommend/IndexRec"
import LeadRec from "../components/recommend/LeadRec"
import BannerRec from "../components/recommend/BannerRec"
import Reports from "../components/reports/Reports"
Vue.use(VueRouter)

const routes = [
  { path: '/', redirect:'/login' },
  { path: '/login', component: Login },
  { path: '/home',
      component: Home ,
      redirect: '/reports',
      children:[
      {path:'/welcome',component: Welcome},
      {path:'/users',component: Users},
      {path:'/categories',component: Category},
      {path:'/specification',component: Specification},
      {path:'/goods',component: Goods},
      {path:'/brands',component: Brands},
      {path:'/orders',component: Orders},
      {path:'/main',component: IndexRec},
      {path:'/lead',component: LeadRec},
      {path:'/banner',component: BannerRec},
      {path:'/reports',component: Reports},
      ]}
]

const router = new VueRouter({
  routes
})

/*router.beforeEach((to, from, next)=>{
  if (to.path=='/login') return next()
  //获取token
  //     next()  放行    next('/login')  强制跳转
  const tokenStr = window.sessionStorage.getItem('token')
  if (!tokenStr) return next('/login')
  next()
})*/
export default router
